﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Chapter03
{
    class Program
    {
        static void Main(string[] args)
        {
            /*
             * 第3章 用泛型实现参数化类型
             * 
             * 3.1 为什么需要泛型
             * 
             * 3.2 日常使用的简单泛型
             * 3.2.1 通过例子来学习：泛型字典
             * 3.2.2 泛型类型和类型参数
             * 3.2.3 泛型方法和判读泛型声明
             * */

            GetCountWords();
        }

        static void GetCountWords()
        {
            string text =
@"Do you like green eggs and ham?
I do not like them, Sam-I-am.
I do not like green eggs and ham.";
            Dictionary<string, int> frequencies = Words.CountWords(text);
            foreach (KeyValuePair<string, int> entry in frequencies)
            {
                string word = entry.Key;
                int frequency = entry.Value;
                Console.WriteLine("{0}: {1}", word, frequency);
            }
        }
    }
}
